﻿@model IEnumerable<LeadMaster.Models.LeadTemplate>
<div id="leadtemplatesindex">
@{
    ViewBag.Title = "Index";
}

<div class="spacer"></div>
@Html.ActionLink("Create New Template", "Create", null, new { style = "font-family: 'Trebuchet MS'; font-size: 14px; color: #666666; font-variant: small-caps"})
<div class="spacer"></div>
<table style="width:400px;">
<tr>
    <td>
    <select id="LeadTemplateID" name="LeadTemplateID" style="width: 200px;">
    @foreach (var item in Model) {        
    <option value="@(item.LeadTemplateID)">@item.Title</option>
    }
    </select>
    </td>
    <td>
        <input type="button" value="Edit" class="EditTemplate"/>
    </td>
    <td>
        <input type="button" value="Clone" class="clonetemplate" />
    </td>
    <td>
    <img src="~/Images/Delete.ico" alt="Delete Template" style="height:25px; width:25px;" class="deletetemplate"/>
    </td>
</tr>
</table>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $('#LeadTemplateID').chosen();

        $('.clonetemplate').click(function () {
            var ans = confirm("Are you sure you wish to Clone this Template ?")
            if (ans == true) {
                var contactURL = '@(Url.Action("Clone", "LeadBuilder"))?id=' + $('#LeadTemplateID').val();
                window.location.href = contactURL;
            }
        });

        $('.EditTemplate').click(function () {
            var templateURL = '@(Url.Action("Edit", "LeadBuilder"))?id=' + $('#LeadTemplateID').val();
            window.location.href = templateURL;
        });

        $('.deletetemplate').click(function () {
            var templateURL = '@(Url.Action("Delete", "LeadBuilder"))?id=' + $('#LeadTemplateID').val();
            window.location.href = templateURL;
        });
    });
</script>